package org.javaboy.demo.dao;

import org.apache.ibatis.annotations.*;
import org.javaboy.demo.model.User;

public interface UserMapper {

    @Select("select * from user where id=#{id};")
    User getUserById(Integer id);

    @Insert("insert into user (username,address) values (#{username},#{address});")
    int addUser(User user);

    @Results(id = "BaseUser", value = {
            @Result(id = true, property = "id", column = "uid"),
            @Result(property = "username", column = "name")
    })
    @Select("select id as uid,username as name,address from user where id=#{id};")
    User getUserById2(Integer id);

    @Result(property = "orders", many = @Many(select = "org.javaboy.demo.dao.OrdersMapper.getOrdersByUid"), column = "id")
    @Select("select * from user where id=#{id};")
    User getUserById3(Integer id);

}
